package com.woniuxy.microstockserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.microstockserver.bean.OutStockBean;
import com.woniuxy.microstockserver.bean.PageRequestBean;
import com.woniuxy.microstockserver.mapper.OutStockMapper;
import com.woniuxy.microstockserver.service.IOutStockService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 赵雄伟
 * 出库单impl
 */
@Service
public class OutStockServiceImpl implements IOutStockService {

    @Resource
    private OutStockMapper outStockMapper;

    @Override
    public PageInfo<OutStockBean> findAllOutStockBean(PageRequestBean pageRequestBean, OutStockBean outStockBean) {
        return PageHelper.startPage(pageRequestBean.getPageNum(),pageRequestBean.getLimit()).
                doSelectPageInfo(()->outStockMapper.findAllOutStockBean(pageRequestBean, outStockBean));
    }

    @Override
    public Long saveOutStockBean(OutStockBean outStockBean) {
        outStockMapper.saveOutStockBean(outStockBean);
        return outStockBean.getId();
    }

    @Override
    public OutStockBean findOutStockAndGoodsDetail(Long id) {
        return outStockMapper.findOutStockAndGoodsDetail(id);
    }

    @Override
    public Long upadteOutStockBean(OutStockBean outStockBean) {
        return outStockMapper.upadteOutStockBean(outStockBean);
    }
}
